Skip to content

Reduce slice allocations during unique insertions#705

Merged
brandur merged 1 commit intomasterfrom
brandur-reduce-allocations
Dec 27, 2024
Merged

Reduce slice allocations during unique insertions#705
brandur merged 1 commit intomasterfrom
brandur-reduce-allocations

Conversation

@brandur
Copy link
Copy Markdown
Contributor

@brandur brandur commented Dec 25, 2024

Just reduce some really easy to avoid slice allocations for every unique
insertion:

  • No reason to have requiredV3states allocated every time a new unique
    opts is validated. It never changes.

  • Leave missingStates unallocated by default. Most of the time a
    unique insertion will have have no missing unique states, so this
    skips a unique allocation completely the overwhelmingly majority of
    the time.

@brandur brandur force-pushed the brandur-reduce-allocations branch from e905811 to 9859d7a Compare December 25, 2024 19:30
Just reduce some really easy to avoid slice allocations for every unique
insertion:

* No reason to have `requiredV3states` allocated every time a new unique
  opts is validated. It never changes.

* Leave `missingStates` unallocated by default. Most of the time a
  unique insertion will have have no missing unique states, so this
  skips a unique allocation completely the overwhelmingly majority of
  the time.
@brandur brandur force-pushed the brandur-reduce-allocations branch from 9859d7a to d5ed285 Compare December 25, 2024 19:33
Copy link
Copy Markdown
Contributor

@bgentry bgentry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good fix! Thanks

@brandur brandur merged commit f88dfff into master Dec 27, 2024
@brandur brandur deleted the brandur-reduce-allocations branch December 27, 2024 00:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants